<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "https://www.w3.org/TR/html4/loose.dtd">
<html lang="zh-CN"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta http-equiv="Content-Language" content="zh-CN"><link href="stylesheet.css" media="all" rel="stylesheet" type="text/css">
<title>ROLLBACK</title>
<script> var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?d286c55b63a3c54a1e43d10d4c203e75"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
</head><body class="REFENTRY">
<div>
<table summary="Header navigation table" width="100%" border="0" cellpadding="0" cellspacing="0">
<tr><th colspan="5" align="center" valign="bottom">PostgreSQL 8.2.3 中文文档</th></tr>
<tr><td width="10%" align="left" valign="top"><a href="sql-revoke.html" accesskey="P">后退</a></td><td width="10%" align="left" valign="top"><a href="sql-revoke.html">快退</a></td><td width="60%" align="center" valign="bottom"></td><td width="10%" align="right" valign="top"><a href="sql-rollback-prepared.html">快进</a></td><td width="10%" align="right" valign="top"><a href="sql-rollback-prepared.html" accesskey="N">前进</a></td></tr>
</table>
<hr align="LEFT" width="100%"></div>
<h1><a name="SQL-ROLLBACK"></a>ROLLBACK</h1>
<div class="REFNAMEDIV"><a name="AEN53355"></a><h2>名称</h2>ROLLBACK&nbsp;--&nbsp;退出当前事务</div>
<a name="AEN53358"></a>
<div class="REFSYNOPSISDIV"><a name="AEN53360"></a><h2>语法</h2>
<pre class="SYNOPSIS">ROLLBACK [ WORK | TRANSACTION ]</pre>
</div>
<div class="REFSECT1"><a name="AEN53362"></a><h2>描述</h2>
<p><tt class="COMMAND">ROLLBACK</tt> 回滚当前事务并取消当前事务中的所有更新。</p>
</div>
<div class="REFSECT1"><a name="AEN53366"></a><h2>参数</h2>
<div class="VARIABLELIST">
<dl>
<dt><tt class="LITERAL">WORK</tt><br><tt class="LITERAL">TRANSACTION</tt></dt>
<dd><p>可选的关键字。没有作用。</p></dd>
</dl>
</div>
</div>
<div class="REFSECT1"><a name="AEN53376"></a><h2>注意</h2>
<p>使用 <a href="sql-commit.html"><i>COMMIT</i></a> 语句将对事务进行提交。</p>
<p>如果不在一个事务内部发出 <tt class="COMMAND">ROLLBACK</tt> 不会有问题，但是将抛出一个警告信息。</p>
</div>
<div class="REFSECT1"><a name="AEN53382"></a><h2>例子</h2>
<p>取消所有更改：</p>
<pre class="PROGRAMLISTING">ROLLBACK;</pre>
</div>
<div class="REFSECT1"><a name="AEN53386"></a><h2>兼容性</h2>
<p>SQL 标准只声明了两种形式 <tt class="LITERAL">ROLLBACK</tt> 和 <tt class="LITERAL">ROLLBACK WORK</tt> 。否则完全兼容。</p>
</div>
<div class="REFSECT1"><a name="AEN53391"></a><h2>又见</h2><a href="sql-begin.html"><i>BEGIN</i></a>, <a href="sql-commit.html"><i>COMMIT</i></a>, <a href="sql-rollback-to.html"><i>ROLLBACK TO SAVEPOINT</i></a></div>
<div>
<hr align="LEFT" width="100%">
<table summary="Footer navigation table" width="100%" border="0" cellpadding="0" cellspacing="0">
<tr><td width="33%" align="left" valign="top"><a href="sql-revoke.html" accesskey="P">后退</a></td><td width="34%" align="center" valign="top"><a href="index.html" accesskey="H">首页</a></td><td width="33%" align="right" valign="top"><a href="sql-rollback-prepared.html" accesskey="N">前进</a></td></tr>
<tr><td width="33%" align="left" valign="top">REVOKE</td><td width="34%" align="center" valign="top"><a href="sql-commands.html" accesskey="U">上一级</a></td><td width="33%" align="right" valign="top">ROLLBACK PREPARED</td></tr>
</table>
</div>
</body></html>